﻿using System.Collections.Generic;

namespace IAD13.fromTDDtoBDD
{
    public class Amount : IAmount
    {
        public ICurrency Currency { get; private set; }
        public decimal Value { get; set; }

        public Amount(decimal value, ICurrency currency)
        {
            Currency = currency;
            Value = value;
        }
        
        public override string ToString()
        {
            return string.Format("{0} {1}",Value,Currency.Value);
        }

        public override bool Equals(object obj)
        {
            var right = (IAmount) obj;
            return Value == right.Value && Currency.Equals(right.Currency);
        }

        public static IAmount OfEuro(decimal amount)
        {
            return new Amount(amount,new Currency("EUR"));
        }

        public static IAmount OfDollar(decimal amount)
        {
            return new Amount(amount, new Currency("USD"));
        }
    }
}